package crp.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class DistanceUtil {
	public static double distance(String document1,String document2){
		double result = 0;
		  try
	        {
	            Runtime r = Runtime.getRuntime();
	            Process p = r.exec("python ./python/distance.py ./document/"+document1+" ./document/"+document2);
	            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
	            p.waitFor();
	            String line = "";
	            result = Double.parseDouble(br.readLine());

	        }
	        catch (Exception e)
	        {
			String cause = e.getMessage();
			if (cause.equals("python: not found"))
				System.out.println("No python interpreter found.");
	        }
		  return result;
	}
}
